<?
$help['sandbox:remove'] = 'removing configuration for branch and branch directory';
$opt['sandbox:remove'] = array('branch', 'dir');

function cmd_sandbox_remove($branch, $dir = false){
    echo "branch:$branch\ndir:$dir\n";
    if(!is_dir($dir)) error('branch directory is not found');
    echo "Branch $branch located in $dir will be removed, you may be asked for password, remove?";
    $r = rline("\nyes/[no]:");
    if($r == 'yes'){
        echo "removing:\n";
        if(unlink(__DIR__ . "/../conf/apache/$dir.conf")) echo "\tconfiguration removed\n";
        echo "\tremoving directory ... ";
        system("sudo rm -fr $dir", $ret);
        if($ret == 0) echo "ok\n";
        echo "\n";
    } else echo "interrupted\n\n";
}